﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Configuration;


namespace DZDToExcel
{
    public partial class Main : Form
    {
        public Main(string[] args)
        {
            InitializeComponent();
            putin = args;

        }


        DZH DZH = new DZH();
        public string EnterpriseName = ConfigurationManager.AppSettings["EnterpriseName"].ToString();
        public string[] putin = null;

        private void Main_Load(object sender, EventArgs e)
        {
            DateTime StartDate = Convert.ToDateTime("2028-12-31");
            TimeSpan span = StartDate.Subtract(DateTime.Now);
            if (putin.Length != 0)
            {
                //MessageBox.Show("试用天数还有" + span.Days.ToString() + "天", "提示", MessageBoxButtons.OK);
                Excel(putin[0]);
                this.Close();
                Application.Exit();
            }
        }  

        private void btnExcel_Click(object sender, EventArgs e)
        {
            Excel(txtdjbh.Text);
        }

        public void Excel(string Number)
        {
            string saveFileName = "";
            SaveFileDialog saveDialog = new SaveFileDialog();
            saveDialog.DefaultExt = "xls";
            saveDialog.Filter = "Excel 2003文件|*.xls";
            saveDialog.FileName = Number;

            if (saveDialog.ShowDialog() == DialogResult.OK)
            {
                saveFileName = saveDialog.FileName;
                DZH.ExportExcel(EnterpriseName, saveFileName, Number);
               // MessageBox.Show(saveFileName + " 保存成功", "提示", MessageBoxButtons.OK);
                FormMSG msg = new FormMSG(Number);
                msg.ShowDialog();
            }
        }
    }
}
